package calendar.messages;

import calendar.Event;
import calendar.User;
import edu.gmu.middleware.Message;
import edu.gmu.streams.BlockInputStream;
import edu.gmu.streams.BlockOutputStream;
import java.io.IOException;

/* this class represents a calendar event */
import java.util.ArrayList;
public class RetrieveResponse implements Message
{ 
  public ArrayList events;

  public RetrieveResponse()
  {
    this.events = null;
  }


  public void marshal(BlockOutputStream stream) throws IOException
  {
    stream.writeInt( this.events.size() );
      for (int i = 0; i < events.size(); i++)
      {
          Event event = (Event)events.get(i);
          event.marshal(stream);
      }
  }

  public void unmarshal(BlockInputStream stream) throws IOException
  {
    int size = stream.readInt();
    this.events = new ArrayList();
      for (int i = 0; i < size; i++)
      {
          Event event = new Event();
          event.unmarshal(stream);
          this.events.add(event);
      }
  }
}
